package com.gg.controller;

import com.gg.pojo.ResultData;
import com.gg.pojo.User;
import com.gg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: YDYX
 * @Date: 2022/1/11 - 01 - 11 - 19:24
 * @Description: com.gg.controller
 * @version: 1.0
 */
@RestController
@RefreshScope
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/sendMsg/{userMobile}")
    public  ResultData sendMsg(@PathVariable String userMobile){
        final ResultData resultData = userService.sendMsg(userMobile);
        return  resultData;
    }
    @PostMapping("/register")
    public ResultData register(@RequestBody User user){
        return userService.register(user);
    }

    @PostMapping("/login")
    public ResultData login(@RequestBody User user){
        return userService.login(user);
    }

    @RequestMapping("/tokenError")
    public  ResultData tokenError(){

        return new ResultData(333,"token不合法");
    }
}
